<!DOCTYPE html>
<html>
    <head>
        <style>
            body {
                margin: 0px;
                padding: 32px;
                font-size: 16px;
                font-family: "Consolas", "Andale Mono", monospace;
            }
            a {
                color: rgb(0, 156, 117);
                text-decoration: none;
            }
            a:hover {
                color: rgb(8, 115, 88);
            }
            code {
                color: rgb(30, 94, 184);
                font-size: inherit;
                font-family: inherit;
            }
            li {
                white-space: pre;
            }
            .banner {
                opacity: 0.75;
                position:fixed;
                right: 32px;
                top: 32px;
            }
        </style>
    </head>
    <body>
        <div class="banner">
            <img src="resources/ferris.svg" height="44px" />
            <img src="resources/wasm.svg" height="44px" />
            <img src="resources/kaspa.svg" height="44px" />
        </div>
        Rusty Kaspa WASM32 SDK v<span id="version"></span><br>&nbsp;<br>
        Packages:<br>
        <ul id="packages"></ul>
        Examples:
        <ul>
            <li><a href="get-block-dag-info.html">getBlockDagInfo</a></li>
            <li><a href="get-server-info.html">getServerInfo</a></li>
            <li><a href="subscribe-block-added.html">subscribeBlockAdded</a></li>
            <li><a href="subscribe-daa-changed.html">subscribeDaaScore</a></li>
            <li><a href="xpub.html">XPub tests</a></li>
            <li><a href="utxo-context.html">UtxoContext</a></li>
        </ul>
    </body>
    <script src="../../package-sizes.js"></script>
    <script>
        if (location.protocol === 'file:') {
            document.body.innerHTML = `
                These examples must be served over HTTP or HTTPS. 
                <p>Try running <code>python3 -m http.server</code> and navigating to <a href="http://localhost:8000/index.html">http://localhost:8000/</a></p>
                <p>If using Rust, install http server by running: <code>cargo install http-server</code>,<br>
                then run <code>http-server</code> and navigate to <a href="http://localhost:7878/index.html">http://localhost:7878/</a></p>
                <p>Make sure to run HTTP server from the root of the <code>kaspa-wasm32-sdk</code> folder.</p>
            `;
        } else {
            if (!window.packageSizes) {
                window.packageSizes = {};
            }
            let el = document.getElementById("packages");
            Object.entries({
                "kaspa-keygen": ["KeyGen","Key & Address Generation only"],
                "kaspa-rpc": ["RPC","RPC only"],
                "kaspa-core": ["Core","RPC + Key & Address Generation + Wallet SDK"],
                "kaspa": ["SDK","Full SDK + Integrated Wallet"],
            }).forEach(([ident,[name,descr]]) => {
                let size = packageSizes[ident] ? `${packageSizes[ident]}` : "";
                el.innerHTML += `<li>WASM32 ${name} Package ${" ".repeat(6-name.length)}${size} - ${descr} - <a href="../../docs/${ident}/index.html" target="_blank">Docs</a></li>`;
                // el.innerHTML += `<li>WASM32 ${name} Package ${" ".repeat(6-name.length)}(${packageSizes[ident]}) - ${descr} - <a href="../../docs/${ident}/index.html" target="_blank">Docs</a></li>`;
            });
        }
    </script>
    <script type="module">
        import * as kaspa from '../../web/kaspa-core/kaspa.js';
        (async () => {
            await kaspa.default('../../web/kaspa-core/kaspa_bg.wasm');
            console.log("kaspa", kaspa);
            console.log("version", kaspa.version());
            document.getElementById("version").innerText = kaspa.version();
        })();
    </script>
</html>